﻿namespace Digitalmes.Infrastructure.Common.Http;

/// <summary>
/// HTTP REST 客户端。
/// </summary>
public interface IGalleryClient : IDisposable
{
    /// <summary>
    /// GET 请求。
    /// </summary>
    /// <typeparam name="TResponse"></typeparam>
    /// <param name="resource">请求的资源地址。</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<TResponse?> GetJsonAsync<TResponse>(string resource, CancellationToken cancellationToken = default);

    /// <summary>
    /// POST 请求。
    /// </summary>
    /// <typeparam name="TRequest"></typeparam>
    /// <typeparam name="TResponse"></typeparam>
    /// <param name="resource">请求的资源地址。</param>
    /// <param name="request">请求的数据。</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<TResponse?> PostJsonAsync<TRequest, TResponse>(string resource, TRequest request, CancellationToken cancellationToken = default) where TRequest : class;

    /// <summary>
    /// PUT 请求。
    /// </summary>
    /// <typeparam name="TRequest"></typeparam>
    /// <typeparam name="TResponse"></typeparam>
    /// <param name="resource">请求的资源地址。</param>
    /// <param name="request">请求的数据。</param>
    /// <param name="cancellationToken"></param>
    /// <returns></returns>
    Task<TResponse?> PutJsonAsync<TRequest, TResponse>(string resource, TRequest request, CancellationToken cancellationToken = default) where TRequest : class;
}
